/**
 * Created with Vim7.3 ubuntu12.04
 * @fileOverview : 
 * @author : Lyle <lylechen2014@gmial.com>
 * @since : 2014-08-25 11:28:23
 * @filename : sea-modules/panel/zepto.panel.js
 * @version : 
 * @description : 
 */
(function(){
 
  var winWidth = window.innerWidth;  
 
  $.fn.panel = {
    
      //全局信息
      info : {},
    
      init : function(opt) {

	   for (var i in opt ) {
	       if ( typeof(this.info[i]) == 'undefined') { 
                    this.info[i] = opt[i];
	       }
	   }

           opt.navDom.find('li').removeClass('action');
           opt.navDom.find('li[nav='+opt.navName+']').addClass('action');

           this.loadData();             
           this.bindEvt();
           this.switchRun();
       },
           
       bindEvt : function() {
           var tthis = this;
       
           $(window).bind('orientationchange',function(){
               winWidth = window.innerWidth;
           });

           this.info.navDom.find('.userNav_menu').on('tap',function(){
               var url = $(this).attr('url');
               if (url) {
	           window.location.href='#'+url+'/whole'; 
               }
           });

           this.info.contentDom.parent().find('.switch').on('tap',function(e){
               e.stopPropagation();
               if (tthis.info.state == 'hidden') {
                   tthis.show();
               } else {
                   tthis.hidden(); 
               }
           }); 
 
           this.info.contentDom.parent().on('tap',function(){
               if (tthis.info.state == 'show') {
                   tthis.hidden();
               }
           });                        


       },

       loadData : function() {
     
       },

       switchRun : function() {
           if (this.info.state == 'hidden') {
               this.hidden();
           } else {
               this.show();
           }
       },

 
       hidden : function() {
           this.info.state = 'hidden';
           if ($(window).width() < 640) {
               this.hiddenLess640();
           } else {
               this.hiddenThan640();
           }  
       },

       show : function() {
           this.info.state = 'show';
           if ($(window).width() < 640) {
               this.showLess640();
           } else {
               this.showThan640();
           } 
       },
        
       hiddenLess640 : function() {
           this.transformCSS(this.info.navDom,-260,200);
           this.transformCSS(this.info.contentDom,0,200);
           this.transformCSS(this.info.rootDom.find('.head'),0,200);
       },

       showLess640 : function() {
           this.transformCSS(this.info.navDom,0,200);
           this.transformCSS(this.info.contentDom,260,200);
           this.transformCSS(this.info.rootDom.find('.head'),260,200);
       },
    
       hiddenThan640 : function() {

       },

       showThan640 : function() {

       },
       
       transformCSS : function(dom,move,time) {
            dom.attr('style','-webkit-transform: translate('+move+'px); -webkit-transition: '+time+'ms linear; -moz-transform: translate('+move+'px); -moz-transition: '+time+'ms linear; transform: translate('+move+'px); transition: '+time+'ms linear;');
       }


    
    };


    if (typeof define === "function" ) {
        define("panel/zepto.panel.js", [], function () { return $.fn.panel;} );
    }

})();

